package com.ss.lambda.demo3;

import java.util.function.Function;

/**
 * @Auther: ljy.s
 * @Date: 2022/9/12 - 09 - 12 - 16:33
 */
public class FunctionLambda {
    // 这是一个main方法，是程序的入口：
    public static void main(String[] args) {
        method(str -> Integer.parseInt(str) + 10,
                str -> str * 10);

        String str = "周七,28";
        int age = getAgeNum(str,
                s -> s.split(",")[1],
                s -> Integer.parseInt(s),
                s -> s -= 10);
        System.out.println("age -= " + age);
    }

    static void method(Function<String, Integer> one, Function<Integer, Integer> two) {
        int num = one.andThen(two).apply("10");
        System.out.println(num + 20);
    }

    static int getAgeNum(String str, Function<String, String> one,
                         Function<String, Integer> two,
                         Function<Integer, Integer> three) {
        return one.andThen(two).andThen(three).apply(str);
    }
}
